package com.example.springvue.mapper;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.springvue.model.AdminUser;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
//@TableName("fa_admin")
public interface AdminUserMapper  extends BaseMapper<AdminUser> {



    @Select("SELECT * FROM admin_user WHERE username=#{username}")
    AdminUser getAdminUserInfoModel(String username);

    @Select("SELECT a.*,aga.group_id FROM admin_user a LEFT JOIN auth_group_access aga ON a.id=aga.uid WHERE  id = #{Id} LIMIT 1")
    AdminUser getAdminUserInfoId(int Id);

    @Select("SELECT a.avatar,a.createtime,a.email,a.id,a.is_chat,a.is_service,a.loginfailure,a.loginip,a.logintime,a.nickname,a.sort,a.status,a.updatetime,a.username" +
            ",aga.group_id,ag.name as group_name FROM admin_user a  JOIN auth_group_access aga ON a.id=aga.uid JOIN auth_group ag ON  aga.group_id=ag.id")
    List<Map<String,Object>> getAdminUserList();
}
